package com.jemmyee.pizza.web.utils;

import java.lang.reflect.InvocationTargetException;

import com.jemmyee.pizza.web.bean.PrivilegeBean;

/**
 * @Description: TODO
 * @author:jemmyee@gmail.com
 * @date:2011-1-5
 * @version:v1.0
 */
public class PrivilegeUtils {
	
	/**
	* @Description:返回得到权限的bean
	* @author:jemmyee@gmail.com
	* @date:2011-1-5
	*/
	public  static PrivilegeBean initPrivileges(String ids)
	{
		PrivilegeBean pb=new PrivilegeBean();
		for(String id:ids.split("_"))
		{
			if(!id.equals(""))
			{
				try {
					pb.getClass().getMethod("setP_"+id, new Class[]{Boolean.class}).invoke(pb, new Object[]{true});
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (SecurityException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				} catch (InvocationTargetException e) {
					e.printStackTrace();
				} catch (NoSuchMethodException e) {
					e.printStackTrace();
				}
			}
		}
		
		return pb;
	}

}
